<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/DeliveryDate/deliveryDate" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="deliveryDate" />
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel" />
            <label >批次号：</label>&nbsp;
            <input type="text" name="lotId" value="${lotId}"/>
            <label >方向：</label>&nbsp;
            <input type="text" name="fangxiang" value="${fangxiang}"/>
            <label >产品编码：</label>&nbsp;
            <input type="text" name="partName"  value="${partName}"/>
            <label >图号：</label>&nbsp;
            <input type="text" name="tuhao" value="${tuhao}"/>
            <label >订单号：</label>&nbsp;
            <input type="text" name="parentId" value="${parentId}"/>
            <label >按期交付数量：</label>&nbsp;
            <input type="text" name="deliveryQty" value="${deliveryQty}"/>
            <label >延误天数大于：</label>&nbsp;
            <input type="text" name="delayDays" value="${delayDays}"/>
            <label >入库时间：</label>&nbsp;
            <input type="text" name="startTime" readonly value="${startTime}" data-rule="required" data-pattern="yyyy-MM-dd"  data-toggle="datepicker" placeholder="FROM">
            <input type="text" name="endTime" readonly value="${endTime}" data-rule="required" data-pattern="yyyy-MM-dd" data-toggle="datepicker" placeholder="TO">&nbsp;&nbsp;
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/OutsourcedProcessing/exportExcel')" data-icon="file-excel-o" title="导出Excel">导出</button>&nbsp;
        </div>
    </form>
</div>

<div class="bjui-pageContent">
    <g:if test="${deliveryDate.size() > 0}">
        <table  data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr id="t1">
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance!='RN'}">
                        <th  width="125"><g:message code="${headInstance}" default="${headInstance}"/></th>
                    </g:if>
                </g:each>
            </tr>
            </thead>
            <tbody>
            <g:if test="${deliveryDate.size()>0}">
                <g:each in="${deliveryDate}" status="i" var="dataInstance">
                    <tr>
                        <g:each in="${tableHeadList}" status="j" var="headInstance">
                            <g:if test="${headInstance=='SL'}">
                                <td name="MAIN${i}">${dataInstance["${headInstance}"]}</td>
                            </g:if>
                            <g:elseif test="${headInstance=='DELIVERY_QTY'}">
                                <td name="DELIVERY${i}">${dataInstance["${headInstance}"]}</td>
                            </g:elseif>
                            <g:elseif test="${headInstance!='RN'}">
                                <td>${dataInstance["${headInstance}"]}</td>
                            </g:elseif>

                        </g:each>
                    </tr>
                </g:each>
                <tr>
                    <td colspan="8">小计</td>
                    <td name="MAINSHOW"></td>
                    <td name="DELIVERYSHOW"></td>


                </tr>
                <tr>
                    <td colspan="8">合计</td>
                    <td>${deliveryDateSumQty.SUM_MAIN[0]}</td>
                    <td>${deliveryDateSumQty.SUM_DELIVERY[0]}</td>
                </tr>

            </g:if>
            <g:else>
                <g:render template="../template/emptyPanel" />
            </g:else>
            </tbody>
        </table>
    </g:if>
</div>
<g:render template="../template/pagination" />
<script>
    $(function(){
        var mainQty=0;
        var deliveryQty=0;
        for(var i=0;i<${deliveryDate.size()};i++){

            var main='MAIN'+i
            var mainAdd=$("td[name='"+main+"']").text()==''?0:parseInt($("td[name='"+main+"']").text());
            mainQty+=mainAdd;

            var delivery='DELIVERY'+i
            var deliveryAdd=$("td[name='"+delivery+"']").text()==''?0:parseInt($("td[name='"+delivery+"']").text());
            deliveryQty+=deliveryAdd;

        }
        $("td[name='MAINSHOW']").html(mainQty);
        $("td[name='DELIVERYSHOW']").html(deliveryQty);


    })
</script>
